#ifndef FARMINFOWIDGET_H
#define FARMINFOWIDGET_H

#include <QWidget>
#include <QSqlQuery>
#include <QGridLayout>
#include <QLabel>
#include <QPushButton>
#include <QTimer>
#include <QSqlError>
#include <QMessageBox>
#include <QDebug>
#include <QGroupBox>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QFormLayout>
#include <QDateTime>
#include <QApplication>
#include <QStyle>
#include <QLineEdit>
#include <QDialogButtonBox>
#include <QDoubleValidator>
#include "envcard.h"
#include "mqttclient.h"
#include "videoplayer.h"

class FarmInfoWidget : public QWidget
{
    Q_OBJECT
public:
    explicit FarmInfoWidget(QWidget *parent = nullptr,QString permission ="rw");

signals:
public slots:
    void loadData(); // 加载数据
    void onPresetClicked(); // 预设按钮点击
    void setFarmId(int farmId); // 设置农场ID
    void onCo2Clicked();
        void onTempClicked();
        void onHumidityClicked();
        void onLightClicked();

private:
    void setupUI();
    void updateDataDisplay();
    void editValue(const QString &title, const QString &unit, double &value);

    // 数据标签
    EnvCard *co2Card;
    EnvCard *tempCard;
    EnvCard *humidityCard;
    EnvCard *lightCard;
    // 数据值
    QString permission;
    double co2Value;
    double tempValue;
    double humidityValue;
    double lightValue;
    MqttClient *clt;
    VideoPlayer* v;


    // 刷新定时器
    QTimer *refreshTimer;

    int farmId = -1;

};

#endif // FARMINFOWIDGET_H
